//导入封装好的axios模块
import requests from "./index";
// 导入格式化插件
import qs from 'qs'
// import axios from "axios";


export const sliders = () => {
    return requests({
        method: 'get',
        url: '/home/sliders'
    })
}

export const category = () => {
    return requests({
        method: 'get',
        url: '/home/category'
    })
}

export const floorlist = () => {
    return requests({
        method: 'get',
        url: '/home/floorlist'
    })
}

export const getProductList = (params) => {
    return requests({
        method: 'get',
        url: '/product/list',
        params: params
    })
}

// 商品详情页数据
export const getProductDetail = (id) => {
    // console.log('接口=====',Number(id));
    return requests({
        method: 'get',
        url: '/product/detail',
        params: { id }
    })
}

// 分类
export const getCategoryData = () => {
    return requests({
        method: 'get',
        url: '/category/data'
    })
}

//登录接口
export const login = (params) => {
    return requests({
        method: 'post',
        url: '/user/login',
        data: qs.stringify(params)
    })
}

//注册
 export const register = (params) => {
    return requests({
        method: 'post',
        url: '/user/register',
        data: qs.stringify(params)
    })
}

//获取用户信息
export const userInfo = () => {
    return requests({
        method: 'get',
        url: '/user/info'
    })
}

//获取用户推荐信息
export const recommend = () => {
    return requests({
        method: 'get',
        url: '/product/recommend'
    })
}

// 退出登录
export const logout = ()=>{
    return requests({
        method:'post',
        url:'/user/logout'
    })
}

//获取购物车数据
export const getCarList = ()=>{
    return requests({
        method:'get',
        url:'/cart/list'
    })
}

//添加商品
export const cartAdd = (params)=>{
    return requests({
        method:'post',
        url:'/cart/add',
        data:qs.stringify(params)
    })
}

//删除购物车数据
 export const delCar = (params) => {
    return requests({
        method:'post',
        url:'/cart/del',
        data:qs.stringify(params)
    })
}